<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>删除</title>
</head>
<body>
    <div id="user">
        <div>
            <label>
                姓名：<input type="text" id="name">
            </label>
        </div>
        <div>
            <label>
                性别：<input type="radio" name="sex" value="1" checked>男
                <input type="radio" name="sex" value="2">女
            </label>
        </div>
    
        <div>
            <label>
                年龄：<input type="text" id="age">
            </label>
        </div>
    
        <div>
            <label>
                大学：<input type="text" id="edu">
            </label>
        </div>
    
        <div>
            <label>
                学号：<input type="text" id="no">
            </label>
        </div>
    
        <div>
            <label>
                城市：
                <select name="" id="city">
                    <option value="1">北京</option>
                    <option value="2">福州</option>
                    <option value="3">厦门</option>
                    <option value="4">龙岩</option>
                    <option value="5">泉州</option>
                </select>
            </label>
        </div>
        <div>
            <button onclick="deliteClick()">删除</button>
        </div>
    </div>
    <script src="ajax.js"></script>
    <script>
        function deliteClick() {
            delite();
        }
    
        function deliteRes(jsonObj) {
            alert("删除成功");
        }
         function delite() {
            let trElement = user.childNodes.childNodes;
             let nameElement = trElement.firstChild.firstChild.nodeValue;
             let flag = window.confirm("你确认要删除"+nameElement+"这个用户吗?");
            if(!flag){
                  // return false的作用就是不让页面自动提交。
                return false;
            }else{
                //确认
                var parentElement = trElement.parentNode;
                parentElement.removeChild(trElement);
                return false;
            }


             ajax("/student/delete.php", "POST", param, deliteRes);
        }
 	
    </script>
</body>
</html>